var deltaTime = 0;
var lastTime = Date.now();


var ani = function(){
	this.dust = new dustObj(); //星空view
	this.pad = new pad(); //平板设备
	this.blue= new blue(); //蓝牙平台
	this.circle = new circleObj();//右上角转圈
	this.car = new car(); //右下仓库
	this.dial = new dial("canvas_power"); //功率
	this.pin = new dial("canvas_pin"); //频率
	this.china = new chinaMap(); //中国地图
}

ani.prototype.init=function(){
	window.onresize = this.size.bind(this);
	this.size();
	this.dust.init();
	this.pad.init();
	this.blue.init();
	this.circle.init();
	this.car.init();
	this.dial.init();
	this.pin.init();
	this.china.init();
	this.loop();
	
}

ani.prototype.loop=function(){
	window.requestAnimationFrame(this.loop.bind(this));
	var now = Date.now();
	deltaTime = now - lastTime;
	lastTime = now;
	if (deltaTime > 40) {
		deltaTime = 40;
	}
	
	this.dust.draw();
	this.pad.draw();
	this.blue.draw();
	this.circle.draw();
	this.car.draw();
	this.dial.draw();
	this.pin.draw();
	this.china.draw();
}

ani.prototype.size=function(){
	// console.log("尺寸改变");
	this.dust.size();
	this.pad.size();
	this.blue.size();
	this.circle.size();
	this.car.size();
	this.dial.size();
	this.pin.size();
	this.china.size();
}